package com.bajiao.common.util;

import java.util.List;
import java.util.Map;

/**
 * @Description: 断言
 * @Author: GuoYu
 * @Date: 2024-10-10/7/2
 * @Version: V1.0
 */
public abstract  class Assert {

    protected Assert() {
    }

    public static void notNull(Object obj, String message) {
        if (obj == null) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void isNull(Object obj, String message) {
        if (obj != null) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void isTrue(Boolean obj, String message) {
        if (!obj) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void notBlank(String obj, String message) {
        if (obj == null || "".equals(obj.trim())) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void  notEmpty(List<?> objList, String message) {
        if (objList == null || objList.size() == 0) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void  notEmpty(Map<?, ?> objMap, String message) {
        if (objMap == null || objMap.size() == 0) {
            throw new IllegalArgumentException(message);
        }
    }

    public static void notEqual(String str1, String str2,String message) {
        if(!str1.equals(str2)){
            throw new IllegalArgumentException(message);
        }
    }
    public static void Equal(String str1, String str2,String message){
        if(str1.equals(str2)){
            throw new IllegalArgumentException(message);
        }
    }
    public static void notPhoneNo(String obj, String message) {
        if(!CheckUtils.Mobile(obj)){
            throw new IllegalArgumentException(message);
        }
    }

    public static void notNumber(String obj, String message) {
        if(!CheckUtils.Z_index(obj)){
            throw new IllegalArgumentException(message);
        }
    }
    public static void notAmt(String obj, String message) {
        if(!CheckUtils.isNumber(obj)){
            throw new IllegalArgumentException(message);
        }
    }
    public static void notIdCard(String obj, String message) {
        if(!CheckUtils.IDcard(obj)){
            throw new IllegalArgumentException(message);
        }
    }

    public static void notTelNo(String obj, String message) {
        if(!CheckUtils.Tel(obj)){
            throw new IllegalArgumentException(message);
        }
    }

    public static void isTelOrPhone(String obj, String message) {
        if(!CheckUtils.Tel(obj)){
            if(!CheckUtils.Mobile(obj)){
                throw new IllegalArgumentException(message);
            }
        }
    }
}
